package IA;



import java.util.ArrayList;
import java.util.List;

/**
 * Class to hold all customer comments in a list
 * @author christopher
 */
public class CommentCollection {

    private Comment customerComment;
    private List<Comment> commentList = new ArrayList<Comment>();

    /**
     * Adds new comment to the commentList
     * @param nameStr
     * @param commentStr
     */
    public void addComment(String nameStr, String commentStr){     
        commentList.add(new Comment(nameStr, commentStr));
    }

    /**
     * Removes comment from list
     * @param comment
     */
    public void removeComment(Integer index){
        commentList.remove(commentList.get(index));
    }
    
    /**
     * Sets the approval of a comment in the commentList
     * @param comment
     * @param isApproved
     */
    public void approveComment(Integer index, Boolean isApproved){
        commentList.get(index)
                .setIsApproved(isApproved);
    }

    /**
     * Gets the list of all comments
     * @return commentList
     */
    public List<Comment> getComments(){
        return commentList;
    }
    
    /*
     * returns formatted to String
     */
    public String toString(){
        String returnStr = "";
        for(Comment comment: commentList){
            returnStr = returnStr.concat(comment.toString()+"/");
        }
        return returnStr.substring(0, returnStr.length()-1);
    }    
}
